<html lang="en">
<head>
    <title>旅游问答管理</title>
    <#include "../common/header.ftl">
    <script type="text/javascript" src="/js/ckeditor/ckeditor.js"></script>
    <script>
        $(function () {
            //富文本编辑器
            var ck = CKEDITOR.replace('content', {
                filebrowserBrowseUrl:'/browser/browse.php',
                filebrowserUploadUrl:'/images/upload.do'
            });
            $(".changeBtninput").click(function () {
                $("#editModalinput").modal("show");
            })

            $(".submitBtninput").click(function () {
                //  手动调用方法 给文本框赋值
                var content = ck.getData();
                $("#content").html(content);

                $("#editForminput").ajaxSubmit(function (data) {
                    if(data.success){
                        window.location.reload();
                    }else(
                            $.messager.confirm("温馨提示","修改出错")
                    )
                })
            });


           $(".changeBtn").click(function () {
               $("#editForm")[0].reset();
               var json = $(this).data("json");
               $("#editForm img").attr("src","");
               if (json){
                   $("#editForm input[name='id']").val(json.id);
                   $("#editForm input[name='title']").val(json.title);
                   $("#editForm input[name='subTitle']").val(json.subTitle);
                   $("#editForm img").attr("src",json.coverUrl);
                   $("#editForm select[name='state']").val(json.state);
                   $("#editForm input[name='coverUrl']").val(json.coverUrl);
               }

               $("#editModal").modal("show");
           });


           $(".submitBtn").click(function () {
               $("#editForm").ajaxSubmit(function (data) {
                   if(data.success){
                       window.location.reload();
                   }else(
                       $.messager.confirm("温馨提示","修改出错")
                   )
               })
           });

            //  日报内容框
            $(".selectContent").click(function () {
                var question = $(this).data("question");
                    $("#showModal .modal-body").html(question);
                $("#showModal").modal("show");
            });

        });
    </script>
    <style>
        /*设置模态框中的图片铺满*/
        #showModal img{
            width: 100%;
        }
        /*当内容大于模态框时,会自定设置滚动条*/
        #showModal .modal-body{
            max-height: 600px;
            overflow-y: auto;
        }
    </style>
</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu="travelQuestion">
<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">旅游问答管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travelQuestion/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}"
                           placeholder="请输入用户昵称">
                </div>
                <button id="btn_query" class="btn btn-info"><span class="glyphicon glyphicon-search"></span> 查询</button>
            </form>

            <table class="table table-striped table-hover" >
                <thead>
                    <tr>
                        <th>编号</th>
                        <th>用户</th>
                        <th>地区</th>
                        <th>发布时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
               <#list result.list as entity>
                   <tr>
                       <td>${entity_index + 1}</td>

                       <td>${(entity.user.nickName)!}</td>

                       <td>${(entity.region.name)!}</td>
                       <td>${(entity.releaseTime?string("yyyy-MM-dd"))!}</td>
                       <td>${entity.stateDisplay!}</td>
                       <td>
                           <a href="javascript:void(0);" class="btn selectContent" data-question='${entity.question}'>查看问题内容</a>
                       </td>
                   </tr>
               </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>

<!---日报内容-->
<div class="modal fade" id="showModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">查看内容</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>

<#--日报, 编辑 新增-->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">日报编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/travelQuestion/saveOrUpdate.do" method="post" id="editForm" enctype="multipart/form-data">
                    <input type="hidden" value="" name="id">

                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="title" value="" placeholder="请输入推荐标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">副标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="subTitle" value="" placeholder="请输入副标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">封面：</label>
                        <div class="col-sm-6">
                            <img src="" alt="封面" width="200px;">
                            <input id="img" type="file" name="file">
                            <input type="hidden" name="coverUrl">
                        </div>
                    </div>

                    <div class="form-group">
                        <label  class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="state" name="state">
                                <option value="-1">全部</option>
                                <option value="0">非头条</option>
                                <option value="1">头条</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary submitBtn">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>

<#--日报, 编辑 新增-->
<div class="modal fade" id="editModalinput">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">日报编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/travelQuestion/saveOrUpdate.do" method="post" id="editForminput" enctype="multipart/form-data">
                    <input type="hidden" value="" name="id">

                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="title" value="" placeholder="请输入推荐标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">副标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="subTitle" value="" placeholder="请输入副标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">封面：</label>
                        <div class="col-sm-6">
                            <img src="" alt="封面" width="200px;">
                            <input id="img" type="file" name="file">
                            <input type="hidden" name="coverUrl">
                        </div>
                    </div>

                    <div class="form-group">
                        <label  class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="state" name="state">
                                <option value="-1">全部</option>
                                <option value="0">非头条</option>
                                <option value="1">头条</option>
                            </select>
                        </div>
                    </div>

                    <textarea name="content.content" id="content" rows="10" cols="80"></textarea>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary submitBtninput">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>